<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="org.jwos.plugin.file.domain.*" %>
<%@ page import="org.jwos.plugin.file.web.*" %>
<%@ page import="org.jwos.platform.ajax.*" %>
<%@ page import="org.jwos.platform.domain.*" %>
<%@ page import="org.jwos.platform.service.*" %>
<%@ page import="org.jwos.plugin.file.service.*" %>
<%
String id = request.getParameter("id");
SessionManager sessionManager = (SessionManager)ServiceFactory.getService(request.getSession().getServletContext(),"sessionManager");
GlobalConfig globalConfig = sessionManager.getGlobalConfig();
FileManager service = (FileManager)ServiceFactory.getService(request.getSession().getServletContext(),"fileManager");
if(!service.isFileInPublishedFolder(id)) {
	response.sendError(HttpServletResponse.SC_FORBIDDEN);
	return;
}
FileInfo info = service.getFileInfoById(session.getId(),id);
List fileList = service.getPublishedFileListByFolderId(id);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Browse Folder</title>
<link rel="stylesheet" type="text/css" href="../style/filetypes.css" />
<style type="text/css">
a { text-decoration: none; color: #40608C; }

.db-ft-thumb { width: 80px; height: 60px; background-repeat: no-repeat; background-position: center center; border: solid 1px #e0e0e0; padding: 2px; background-color: #fff; float: left; }

/* ----- Content ----- */
#content { min-height:500px; height:auto !important; height:500px; background-color: #fff; padding: 10px 20px; }

/* ----- Grid ------ */
table.grd { margin-top: 20px; width: 95%; margin: 20px auto 10px auto; color: #999; }
    table.grd th { border: solid 1px #D6D2C2; background-color: #EBEADB; font-weight: normal; color: #000; font-size: 11px; padding: 3px; text-align: left; }
    table.grd td { border: solid 1px #F1EFE2; padding: 3px; }    
    table.grd tr.alt td { background-color: #FCFAF6; }
    table.grd td.colName { padding-left: 5px;}    
        table.grd td.colName img { margin-right: 5px;}
        table.grd td.colName a { color: #000;}
        table.grd td.colName a:hover { text-decoration: underline; }    
    table.grd td.colModified { width: 150px; }
    table.grd td.colSize { width: 90px; }   
</style>
</head>
<body>
<div id="content">                
	<h3><%=info.getName()%></h3>
	<p><%=info.getDescription()%></p>
	<table class="grd">
		<tr>
			<th>Name</th><th>Last Modified</th><th>Size</th>
		</tr>
<%
for(int i=0;i<fileList.size();i++) {
	FileInfo file = (FileInfo)fileList.get(i);
	String url = "#";
	if(file.isFolder()) {
		url = globalConfig.getCompleteBaseUrl()+ "/file/public/browse?id="+file.getId();
	} else {
		url = globalConfig.getCompleteBaseUrl()+ "/file/public/download?id="+file.getId();
	}
%>
		<tr class="alt">
			<td class="colName">
				<table cellpadding='0' width="100%">
					<tr>
						<td width="90px"><a href='<%=url%>'><img src='../../desktop/images/shared/blank.gif' alt='' class='db-ft-thumb db-ft-<%=file.getIcon()%>-large' /></a></td>
						<td><a href='<%=url%>'><%=file.getName()%></a></td>
					</tr>
				</table>
			</td>
			<td class="colModified"><%=file.getDateModified()%></td>
			<td class="colSize"><%=FolderType.formatSize(file.getSize())%></td>
		</tr>
<%}%>
	</table>
</div>

</body>
</html>